﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>监控地址管理</title>
	<link rel="stylesheet" href="/scriptZIP/vue-select.min.css">
	<link rel="stylesheet" href="css/common2.css">

	<style>
		.add,
		.add2 {
			width: 175px;
			height: 35px;
			text-align: center;
			font-size: 16px;
			line-height: 35px;
			color: white;
			padding-left: 20px;
			display: inline-block;
			background-size: 180px 35px;
			background-repeat: no-repeat;
			background-position: 5% 0;
			background-attachment: local;
			background-image: url("image/add_long.png") !important;
		}

		.two {
			width: 10%;
		}


		.three {
			width: 9%;
		}

		.search_img {
			position: absolute;
			right: 3%;
		}

		.refresh {
			margin-left: 0;
		}

		.vs__dropdown-toggle {
			border: none;
			height: 100%;

		}

		.search {
			background-color: white;
		}
	</style>
</head>

<body>

	<div id="vue-root" style="margin-top: 20px;">
		<div class="add"><a href="live_address_item_public.html" style="color: white">添加公共区域监控</a></div>
		<div class="add2"><a href="live_address_item_school.html" style="color: white">添加教学区域监控</a>
		</div>
		<div class="refresh" onclick="location.reload()">刷新</div>

		<v-select class="search" placeholder="请选择学校" label="name" :options="schools" :reduce="item=>item.id"
			v-model="search.schoolId">
		</v-select>

		<img src="image/search.png" height="35" width="35" class="search_img" @click="getData0">
		<div class="table ">
			<table class="table_top">
				<thead>
					<tr>
						<th class="two">
							<input type="checkbox" class="check-box" v-model="all">
						</th>
						<th>序号</th>
						<th class="four">学校名称</th>
						<!-- <th class="two">设备名称</th> -->
						<th class="two">设备序列号</th>
						<th class="two">通道号</th>
						<th class="two">所在区域</th>
						<th class="four">区域名称</th>
						<!-- <th class="four">设备对接地址</th> -->
						<th class="one">是否收费</th>

						<th class="two" v-if="able.edit||able.del">编辑/删除</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(live,index) in list" :key="live.id">
						<td class="one">
							<input type="checkbox" class="check-box" v-model="live.checked">
						</td>
						<td><span v-text="index+1"></span></td>
						<td v-text="live.schoolName"></td>

						<td>
							<span v-if="live.channelNo>=0||live.channelNo==-3" v-text="live.deviceSerial"></span>
							<button v-else class="btn" :data-clipboard-text="addr(live)">复制推流地址</button>
						</td>

						<td v-text="live.channelNo>=0?live.channelNo:['','本系统','阿里云','海康'][-live.channelNo]">
						</td>
						<td v-text="['公共区域','教学区域'][live.type]"></td>
						<td v-text="live.area"></td>

						<td v-text="live.paid?'是':'否'"></td>

						<td v-if="able.edit||able.del">
							<div v-if="able.edit" class="option">
								<div class="edit-icon option-icon" @click="edit(live)"
									style="position: absolute; left: 20%; top: 30%;">
									<img class="img" src="../image/edit.png" height="20" width="20"
										onmouseover="this.src='image/edit_light.png'"
										onmouseout="this.src='image/edit.png'" />
								</div>
								<div v-if="able.del" class="delete-icon option-icon" @click="del([live.id])"
									style="right: 20%; top:30%;position: absolute;">
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='image/delete_light.png'"
										onmouseout="this.src='image/delete.png'" />
								</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="delete" @click="batchDelete" v-if="able.del||total>1">批量删除</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
			<li>
				<a v-text="pages"></a>
				<!--页面总数-->
			</li>
		</ul>
		<div style="float: right;margin-bottom: 20px;" v-if="pages>1">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<!--style="margin-top: 14px;"-->
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>
	</div>
	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/vue-select.min.js"></script>
	<script src="/scriptZIP/clipboard.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>
		Vue.component('v-select', VueSelect.VueSelect);

		var app = new Vue(merge({
			data: {
				schools: [],
				urls: {
					del: '/pc/live/del',
					list: '/pc/live/list'
				}
			},
			created: function () {
				var url = '/pc/school/all';

				if (/agent/.test(top.location.href)) {
					this.search.agentId = top_params().id;
					url += '/' + top_params().id;
				}

				this.getData();
				axios.get(url).then(function (res) {
					this.schools = res.data;
				}.bind(this));
				abled('live', this);
			},
			methods: {
				edit: function (a) {
					var s = a.type == 0 ? 'public' : 'school';
					location.href = 'live_address_item_' + s + '.html?id=' + a.id;
				},
				addr: function (live) {
					return 'rtmp://' + (live.channelNo == -1 ? location.host + '/dash/' + live.deviceSerial : 't.yoyo51.net' + live.url);
				},
			},
			watch: {
				list: function (newValue, oldValue) {
					this.$nextTick(function () {
						new ClipboardJS('.btn');
					});
				}
			}
		}));
	</script>

</body>

</html>